package com.application.service.Impl;

import com.application.dao.RequestDao;
import com.application.dao.UserDao;
import com.application.domain.User;
import com.application.domain.request;
import com.application.service.RequestService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.ApiOperation;
import org.omg.CORBA.PUBLIC_MEMBER;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@ApiOperation("用户申请")
@Service
public class RequestServiceImpl implements RequestService {

    @Autowired
    private RequestDao requestDao;

    @Autowired
    UserDao userDao;


    @Override
    public int save(request Request) {
        int insert = requestDao.insert(Request);
        return insert;
    }

    @Override
    public int updateById(request request) {
        int updateById = requestDao.updateById(request);
        return updateById;
    }

    @Override
    public request selectById(String openid) {
        request request = requestDao.selectById(openid);
        return request;
    }

    @Override
    public List<request> selectAll() {
        List<request> requestList = requestDao.selectList(null);
        return requestList;
    }

    @Override
    public int deleteById(String openid) {
        LambdaQueryWrapper<request> lqw = new LambdaQueryWrapper<>();
        lqw.eq(request::getOpenid,openid);
        int deleteById = requestDao.delete(lqw);
        return deleteById;
    }

    @Override
    public List<request> selectByName(String name) {
//        LambdaQueryWrapper<request> lqw = new LambdaQueryWrapper<>();
//        lqw.eq(request::getName1,name);
//        List<request> requests = requestDao.selectList(lqw);
        List<request> requests = requestDao.getActibityByName(name);
        return requests;
    }

    @Override
    public int ACT_CheckByOpenid(String openid) {
        int checkByOpenid = requestDao.ACT_CheckByOpenid(openid);
        return checkByOpenid;
    }

    public int COM_CheckByOpenid(String openid){
        int com_checkByOpenid = requestDao.COM_CheckByOpenid(openid);
        return com_checkByOpenid;
    }

    @Override
    public int isSame(String openid, String act_name) {
        int same = requestDao.isSame(openid, act_name);
        return same;
    }

    @Override
    public List<request> selectByCom_name(String com_name) {
        List<request> requests = requestDao.selectByCom_nameRequests(com_name);
        return requests;
    }

    @Override
    public String selectComName(String openid) {
        String com_name = requestDao.getCom_name(openid);
        return com_name;
    }

    @Override
    public List<request> selectByOpenidForAct(String openid) {
        List<request> requests = requestDao.selectByOpenidForAct(openid);
        return requests;
    }

    @Override
    public List<request> getActivityByOpenid(String openid) {
        List<request> activityByOpenid = requestDao.getActivityByOpenid(openid);

        return activityByOpenid;
    }
}
